﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;

namespace com.lover.astd.common.logicexe.secretary
{
    public class SecretaryExe : ExeBase
    {
        private long daily_task_cd = 0;
        public SecretaryExe() { _name = ConfigStrings.S_Secretary; _readable = ConfigStrings.SR_Secretary; }
        public override long execute()
        {
            Dictionary<string, string> conf = getConfig();

            // 领取俸禄/开450以上的箱子/领取礼包/领取军令/领取农场/领取矿场/领取国家任务奖励/每日任务
            MiscMgr mgr = ServiceFactory.getMiscManager();
            long get_token_cd = 0;
            int result = mgr.handleSecretaryInfo(_proto, _logger, out get_token_cd);
            mgr.handleGiftInfo(_proto, _logger);
            mgr.handleNationTreasureInfo(_proto, _logger);
            mgr.handleNationTaskInfo(_proto, _logger, _user);
            mgr.handleDailyEventInfo(_proto, _logger);
            mgr.handleOfficerInfo(_proto, _logger);

            if (conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true"))
            {
                result = mgr.handleDailyTaskInfo(_proto, _logger);
                if (result == 0) daily_task_cd = 22 * 60 * 1000;
                else if (result == 2) daily_task_cd = next_hour();
                else daily_task_cd = 0;
            }

            if (get_token_cd > 0)
            {
                if (get_token_cd > daily_task_cd) return get_token_cd;
                return daily_task_cd;
            }
            else if (daily_task_cd > 0) return daily_task_cd;
            return next_hour();
        }
    }
}
